<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 君未洋
  Date: 2021/8/10
  Time: 11:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script src="static/js/jquery-3.6.0.js"></script>
    <title>测试用</title>

    <script>
        /*$(function(){
            $("#btn").click(function (){
                $.post("${pageContext.request.contextPath}/a2",function (data) {
               /!*这里是使用简化版的操作,里面传入的参数是url,data(可省略) success操作*!/
                    var html="";
                    for(var i=0;i<data.length;i++){
                        html+="<h3>"+data[i].name+"<h3>"
                        html+="<h3>"+data[i].age+"<h3>"
                        html+="<h3>"+data[i].sex+"<h3>"
                        html+="<hr>"
                    }
                    $("#content").html(html);
               })
           })
       });*/
    </script>
</head>
<body>

<input type="button" value="开始加载" id="btn" onclick="go()">
<div id="content"></div>

<script>
    function go() {
        $.post("${pageContext.request.contextPath}/a2", function (data) {
            /*这里是使用简化版的操作,里面传入的参数是url,data(可省略) success操作*/
            var html = "";
            for (var i = 0; i < data.length; i++) {
                html += "<h3>" + data[i].name + "<h3>"
                html += "<h3>" + data[i].age + "<h3>"
                html += "<h3>" + data[i].sex + "<h3>"
                html += "<hr>"
            }
            $("#content").html(html);
        })
    }
</script>

</body>
</html>
